package 曾世昌12_9.zuoye3;

import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

import java.util.ArrayList;
import java.util.List;

public class demo {
    public static void main(String[] args) throws Exception {
        ArrayList<stu> stus = new ArrayList<>();
        SAXReader saxReader = new SAXReader();
        Document read = saxReader.read( "E:\\untitled5\\src\\mxdx3\\day6\\zuoye3\\stu.xml" );
        Element rootElement = read.getRootElement();
        List<Element> student = rootElement.elements( "student" );
        for (Element element : student) {
           stus.add( new stu( element.attributeValue( "stuNo" ),element.elementText( "name" ),Integer.parseInt( element.elementText( "age" ) ),element.elementText( "sex" ),Integer.parseInt( element.elementText( "score" ) ) ) );
        }
        System.out.println(stus);
    }
}
